package com.zzpct.wh.work.maactivity;

import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;


public class SecondFragment extends Fragment {


    //private OnFragmentInteractionListener mListener;

        @Override
        public View onCreateView (LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState){

            View view = inflater.inflate(R.layout.fragment_second, container, false);
            BarChart bar = view.findViewById(R.id.bar_Chart);


            List<BarEntry> barList=new ArrayList<>();
            List<BarEntry> mBarList=new ArrayList<>();
            for (int i = 0; i <5 ; i++) {
                barList.add(new BarEntry(i,new Random().nextInt(20)));
                mBarList.add(new BarEntry(i,new Random().nextInt(25)));

            }
            BarDataSet barDataSet=new BarDataSet(barList,"男");
            barDataSet.setColor(Color.GREEN);
            BarDataSet barDataSet1=new BarDataSet(barList,"女");
            barDataSet.setColor(Color.YELLOW);
            BarData barData=new BarData(barDataSet);
            barData.addDataSet(barDataSet1);
            bar.setData(barData);

            bar.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);

            bar.getAxisRight().setEnabled(false);
            barData.setBarWidth(0.2f);

            bar.groupBars(1,0.6f,0);

            return view;
        }
    }